﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Gencode.SQLWizz.Controls;

namespace Gencode.SQLWizz
{
	public partial class SQLWizzControler : Gencode.Gengui.Wizzard.WizzardDialog
	{
		public SQLWizzControler()
		{
			InitializeComponent();
			InitializeControls();
		}

		private void InitializeControls()
		{
			AddControl("greet", new Greet(string.Empty, "logon", this));
			AddControl("logon", new Logon(string.Empty, "newdatabase", this));
            AddControl("newdatabase", new CreateDatabase("logon", "end", this));
            AddControl("upddatabase", new UpdateDatabase("logon", "end", this));
            

			AddControl("end", new End(string.Empty, string.Empty, this));
			//RepositionButtons();
		}

		public override void Finish()
		{
			this.Close();
		}

		private void SQLWizzControler_FormClosed(object sender, FormClosedEventArgs e)
		{
			DeleteTmpDirectory();
		}

		private void DeleteTmpDirectory()
		{
			if (System.IO.Directory.Exists(@"SQL\tmp"))
			{
				GC.Collect();
				System.IO.Directory.Delete(@"SQL\tmp", true);
				Gencode.Common.ActionLogger.Logger.LoggMessage(Gencode.Common.ActionLogger.MessageType.SQL, "Delete directory SQL\\tmp");
			}
		}
	}
}
